﻿using System;
using System.IO;

namespace Sustainalytics.PregenerateScreeningReports.Service
{
    public class MaximalReportHelper
    {
        public static string ComposeMaximalReportName(Guid sessionId, Guid reportId, string tempPath)
        {
            return Path.Combine(tempPath, string.Format("RM_{2}_{0}_{1}.xlsx", sessionId, reportId, DateTime.Now.ToString("yyMMdd_hhmmss")));
        }
        public static Guid ReportIdFromMaximalReportName(string name)
        {
            var filename = Path.GetFileNameWithoutExtension(name);
            return Guid.Parse(filename.Split(new char[] { '_', '.', ' ' }, StringSplitOptions.RemoveEmptyEntries)[4]);
        }
        public static Guid SessionIdFromMaximalReportName(string name)
        {
            var filename = Path.GetFileNameWithoutExtension(name);
            return Guid.Parse(filename.Split(new char[] { '_', '.', ' ' }, StringSplitOptions.RemoveEmptyEntries)[3]);
        }
    }
}
